<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //  检测是否是2到4位汉字
    const reg = /^[\u4e00-\u9fa5]{2,4}$/;
    const str = "我是测试的字符串";
    const str1 = "字符串";
    console.log(reg.test(str));
    console.log(reg.test(str1));
</script>
</html>